﻿#Region "Copyright"

' Copyright 2007 Ben Reichelt - http://benreichelt.net
' 
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
' 
'     http://www.apache.org/licenses/LICENSE-2.0
' 
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.


#End Region

Public Class AppContext

    Private _server As String = String.Empty
    Public Property Server() As String
        Get
            Return _server
        End Get
        Set(ByVal value As String)
            _server = value
        End Set
    End Property

    Private _database As String = String.Empty
    Public Property Database() As String
        Get
            Return _database
        End Get
        Set(ByVal value As String)
            _database = value
        End Set
    End Property

    Private _user As String = String.Empty
    Public Property UserName() As String
        Get
            Return _user
        End Get
        Set(ByVal value As String)
            _user = value
        End Set
    End Property

    Private _password As String = String.Empty
    Public Property Password() As String
        Get
            Return _password
        End Get
        Set(ByVal value As String)
            _password = value
        End Set
    End Property

    Private _outputXmlFilePath As String = String.Empty
    Public Property OutputXmlFilePath() As String
        Get
            If String.IsNullOrEmpty(_outputXmlFilePath) Then
                Return "output.xml"
            End If
            Return _outputXmlFilePath
        End Get
        Set(ByVal value As String)
            _outputXmlFilePath = value
        End Set
    End Property

    Private _outputCodeFilePath As String = String.Empty
    Public Property OutputCodeFilePath() As String
        Get
            If String.IsNullOrEmpty(_outputCodeFilePath) Then
                Return "output." & CodeFileExtension
            End If
            Return _outputCodeFilePath
        End Get
        Set(ByVal value As String)
            _outputCodeFilePath = value
        End Set
    End Property

    Private _archiveFilePath As String = String.Empty
    Public Property ArchiveFilePath() As String
        Get
            If String.IsNullOrEmpty(_archiveFilePath) Then
                Return "output.original.xml"
            End If
            Return _archiveFilePath
        End Get
        Set(ByVal value As String)
            _archiveFilePath = value
        End Set
    End Property

    Private _namespace As String
    Public Property GeneratedNamespace() As String
        Get
            If String.IsNullOrEmpty(_namespace) Then
                Return "Generated.By.SqlPlastic"
            End If
            Return _namespace
        End Get
        Set(ByVal value As String)
            _namespace = value
        End Set
    End Property

    Private _sqlMetalLocation As String
    Public Property SqlMetalLocation() As String
        Get
            If String.IsNullOrEmpty(_sqlMetalLocation) Then
                Return IO.Path.Combine( _
                                       IO.Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.System)).FullName, _
                                       "Microsoft.NET\Framework\v3.5\sqlmetal.exe")
            End If
            Return _sqlMetalLocation
        End Get
        Set(ByVal value As String)
            _sqlMetalLocation = value
        End Set
    End Property

    Private _language As Language = SqlPlastic.Language.CSharp
    Public ReadOnly Property Language() As Language
        Get
            Return _language
        End Get
    End Property

    Public Sub SetLanguage(ByVal language As String)
        If String.Equals("vb", language, StringComparison.CurrentCultureIgnoreCase) Then
            _language = SqlPlastic.Language.VB
            Return
        ElseIf String.Equals("cs", language, StringComparison.CurrentCultureIgnoreCase) Then
            _language = SqlPlastic.Language.CSharp
            Return
        End If
        Throw New ArgumentException("The language specified was unknown", "language")
    End Sub


    Public ReadOnly Property CodeFileExtension() As String
        Get
            If Language = SqlPlastic.Language.VB Then
                Return "vb"
            End If
            Return "cs"
        End Get
    End Property

    Private _logger As ILogger
    Public Property Logger() As ILogger
        Get
            Return _logger
        End Get
        Set(ByVal value As ILogger)
            _logger = value
        End Set
    End Property

End Class
